<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>cmath</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Chapter 1. Boost.Core">
<link rel="up" href="../index.html" title="Chapter 1. Boost.Core">
<link rel="prev" href="checked_delete.html" title="checked_delete">
<link rel="next" href="default_allocator.html" title="default_allocator">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="checked_delete.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="default_allocator.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="core.cmath"></a><a class="link" href="cmath.html" title="cmath">cmath</a>
</h2></div></div></div>
<div class="toc"><dl class="toc"><dt><span class="section"><a href="cmath.html#core.cmath.header_boost_core_cmath_hpp">Header &lt;boost/core/cmath.hpp&gt;</a></span></dt></dl></div>
<div class="simplesect">
<div class="titlepage"><div><div><h3 class="title">
<a name="idm4027"></a>Authors</h3></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
          Peter Dimov
        </li></ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="core.cmath.header_boost_core_cmath_hpp"></a><a class="link" href="cmath.html#core.cmath.header_boost_core_cmath_hpp" title="Header &lt;boost/core/cmath.hpp&gt;">Header &lt;boost/core/cmath.hpp&gt;</a>
</h3></div></div></div>
<p>
        The header <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">cmath</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
        defines, in a portable way, the floating point classification and sign manipulation
        functions from C++11.
      </p>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="core.cmath.header_boost_core_cmath_hpp.synopsis"></a><a class="link" href="cmath.html#core.cmath.header_boost_core_cmath_hpp.synopsis" title="Synopsis">Synopsis</a>
</h4></div></div></div>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">core</span>
<span class="special">{</span>

<span class="comment">// fpclassify return values</span>

<span class="keyword">int</span> <span class="keyword">const</span> <span class="identifier">fp_zero</span> <span class="special">=</span> <span class="comment">/*unspecified*/</span><span class="special">;</span>
<span class="keyword">int</span> <span class="keyword">const</span> <span class="identifier">fp_subnormal</span> <span class="special">=</span> <span class="comment">/*unspecified*/</span><span class="special">;</span>
<span class="keyword">int</span> <span class="keyword">const</span> <span class="identifier">fp_normal</span> <span class="special">=</span> <span class="comment">/*unspecified*/</span><span class="special">;</span>
<span class="keyword">int</span> <span class="keyword">const</span> <span class="identifier">fp_infinite</span> <span class="special">=</span> <span class="comment">/*unspecified*/</span><span class="special">;</span>
<span class="keyword">int</span> <span class="keyword">const</span> <span class="identifier">fp_nan</span> <span class="special">=</span> <span class="comment">/*unspecified*/</span><span class="special">;</span>

<span class="comment">// Classification functions</span>

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">bool</span> <span class="identifier">isfinite</span><span class="special">(</span> <span class="identifier">T</span> <span class="identifier">x</span> <span class="special">);</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">bool</span> <span class="identifier">isnan</span><span class="special">(</span> <span class="identifier">T</span> <span class="identifier">x</span> <span class="special">);</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">bool</span> <span class="identifier">isinf</span><span class="special">(</span> <span class="identifier">T</span> <span class="identifier">x</span> <span class="special">);</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">bool</span> <span class="identifier">isnormal</span><span class="special">(</span> <span class="identifier">T</span> <span class="identifier">x</span> <span class="special">);</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">int</span> <span class="identifier">fpclassify</span><span class="special">(</span> <span class="identifier">T</span> <span class="identifier">x</span> <span class="special">);</span>

<span class="comment">// Sign manipulation functions</span>

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">bool</span> <span class="identifier">signbit</span><span class="special">(</span> <span class="identifier">T</span> <span class="identifier">x</span> <span class="special">);</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">T</span> <span class="identifier">copysign</span><span class="special">(</span> <span class="identifier">T</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">y</span> <span class="special">);</span>

<span class="special">}</span> <span class="comment">// namespace core</span>
<span class="special">}</span> <span class="comment">// namespace boost</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="core.cmath.header_boost_core_cmath_hpp.classification_functions"></a><a class="link" href="cmath.html#core.cmath.header_boost_core_cmath_hpp.classification_functions" title="Classification Functions">Classification
        Functions</a>
</h4></div></div></div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="core.cmath.header_boost_core_cmath_hpp.classification_functions.template_class_t_bool_isfinite_t"></a><a class="link" href="cmath.html#core.cmath.header_boost_core_cmath_hpp.classification_functions.template_class_t_bool_isfinite_t" title="template&lt;class T&gt; bool isfinite( T x );">template&lt;class
          T&gt; bool isfinite( T x );</a>
</h5></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
                <span class="bold"><strong>Requires:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code>
                must be <code class="computeroutput"><span class="keyword">float</span></code>, <code class="computeroutput"><span class="keyword">double</span></code>, or <code class="computeroutput"><span class="keyword">long</span>
                <span class="keyword">double</span></code>.
              </li>
<li class="listitem">
                <span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="keyword">true</span></code>
                when <code class="computeroutput"><span class="identifier">x</span></code> is finite
                (not infinity or NaN), <code class="computeroutput"><span class="keyword">false</span></code>
                otherwise.
              </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="core.cmath.header_boost_core_cmath_hpp.classification_functions.template_class_t_bool_isnan_t_x"></a><a class="link" href="cmath.html#core.cmath.header_boost_core_cmath_hpp.classification_functions.template_class_t_bool_isnan_t_x" title="template&lt;class T&gt; bool isnan( T x );">template&lt;class
          T&gt; bool isnan( T x );</a>
</h5></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
                <span class="bold"><strong>Requires:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code>
                must be <code class="computeroutput"><span class="keyword">float</span></code>, <code class="computeroutput"><span class="keyword">double</span></code>, or <code class="computeroutput"><span class="keyword">long</span>
                <span class="keyword">double</span></code>.
              </li>
<li class="listitem">
                <span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="keyword">true</span></code>
                when <code class="computeroutput"><span class="identifier">x</span></code> is NaN, <code class="computeroutput"><span class="keyword">false</span></code> otherwise.
              </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="core.cmath.header_boost_core_cmath_hpp.classification_functions.template_class_t_bool_isinf_t_x"></a><a class="link" href="cmath.html#core.cmath.header_boost_core_cmath_hpp.classification_functions.template_class_t_bool_isinf_t_x" title="template&lt;class T&gt; bool isinf( T x );">template&lt;class
          T&gt; bool isinf( T x );</a>
</h5></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
                <span class="bold"><strong>Requires:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code>
                must be <code class="computeroutput"><span class="keyword">float</span></code>, <code class="computeroutput"><span class="keyword">double</span></code>, or <code class="computeroutput"><span class="keyword">long</span>
                <span class="keyword">double</span></code>.
              </li>
<li class="listitem">
                <span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="keyword">true</span></code>
                when <code class="computeroutput"><span class="identifier">x</span></code> is infinity,
                <code class="computeroutput"><span class="keyword">false</span></code> otherwise.
              </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="core.cmath.header_boost_core_cmath_hpp.classification_functions.template_class_t_bool_isnormal_t"></a><a class="link" href="cmath.html#core.cmath.header_boost_core_cmath_hpp.classification_functions.template_class_t_bool_isnormal_t" title="template&lt;class T&gt; bool isnormal( T x );">template&lt;class
          T&gt; bool isnormal( T x );</a>
</h5></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
                <span class="bold"><strong>Requires:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code>
                must be <code class="computeroutput"><span class="keyword">float</span></code>, <code class="computeroutput"><span class="keyword">double</span></code>, or <code class="computeroutput"><span class="keyword">long</span>
                <span class="keyword">double</span></code>.
              </li>
<li class="listitem">
                <span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="keyword">true</span></code>
                when <code class="computeroutput"><span class="identifier">x</span></code> is a normal
                number (not zero, subnormal, infinity, or NaN), <code class="computeroutput"><span class="keyword">false</span></code>
                otherwise.
              </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="core.cmath.header_boost_core_cmath_hpp.classification_functions.template_class_t_int_fpclassify_"></a><a class="link" href="cmath.html#core.cmath.header_boost_core_cmath_hpp.classification_functions.template_class_t_int_fpclassify_" title="template&lt;class T&gt; int fpclassify( T x );">template&lt;class
          T&gt; int fpclassify( T x );</a>
</h5></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
                <span class="bold"><strong>Requires:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code>
                must be <code class="computeroutput"><span class="keyword">float</span></code>, <code class="computeroutput"><span class="keyword">double</span></code>, or <code class="computeroutput"><span class="keyword">long</span>
                <span class="keyword">double</span></code>.
              </li>
<li class="listitem">
                <span class="bold"><strong>Returns:</strong></span>
                <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
                      <code class="computeroutput"><span class="identifier">fp_zero</span></code> when
                      <code class="computeroutput"><span class="identifier">x</span></code> is zero;
                    </li>
<li class="listitem">
                      <code class="computeroutput"><span class="identifier">fp_subnormal</span></code>
                      when <code class="computeroutput"><span class="identifier">x</span></code> is subnormal;
                    </li>
<li class="listitem">
                      <code class="computeroutput"><span class="identifier">fp_infinite</span></code>
                      when <code class="computeroutput"><span class="identifier">x</span></code> is infinity;
                    </li>
<li class="listitem">
                      <code class="computeroutput"><span class="identifier">fp_nan</span></code> when
                      <code class="computeroutput"><span class="identifier">x</span></code> is NaN;
                    </li>
<li class="listitem">
                      <code class="computeroutput"><span class="identifier">fp_normal</span></code> otherwise.
                    </li>
</ul></div>
              </li>
</ul></div>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="core.cmath.header_boost_core_cmath_hpp.sign_manipulation_functions"></a><a class="link" href="cmath.html#core.cmath.header_boost_core_cmath_hpp.sign_manipulation_functions" title="Sign Manipulation Functions">Sign
        Manipulation Functions</a>
</h4></div></div></div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="core.cmath.header_boost_core_cmath_hpp.sign_manipulation_functions.template_class_t_bool_signbit_t_"></a><a class="link" href="cmath.html#core.cmath.header_boost_core_cmath_hpp.sign_manipulation_functions.template_class_t_bool_signbit_t_" title="template&lt;class T&gt; bool signbit( T x );">template&lt;class
          T&gt; bool signbit( T x );</a>
</h5></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
                <span class="bold"><strong>Requires:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code>
                must be <code class="computeroutput"><span class="keyword">float</span></code>, <code class="computeroutput"><span class="keyword">double</span></code>, or <code class="computeroutput"><span class="keyword">long</span>
                <span class="keyword">double</span></code>.
              </li>
<li class="listitem">
                <span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="keyword">true</span></code>
                when <code class="computeroutput"><span class="identifier">x</span></code> is negative,
                <code class="computeroutput"><span class="keyword">false</span></code> otherwise.
              </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="core.cmath.header_boost_core_cmath_hpp.sign_manipulation_functions.template_class_t_bool_copysign_t"></a><a class="link" href="cmath.html#core.cmath.header_boost_core_cmath_hpp.sign_manipulation_functions.template_class_t_bool_copysign_t" title="template&lt;class T&gt; bool copysign( T x, T y );">template&lt;class
          T&gt; bool copysign( T x, T y );</a>
</h5></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
                <span class="bold"><strong>Requires:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code>
                must be <code class="computeroutput"><span class="keyword">float</span></code>, <code class="computeroutput"><span class="keyword">double</span></code>, or <code class="computeroutput"><span class="keyword">long</span>
                <span class="keyword">double</span></code>.
              </li>
<li class="listitem">
                <span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="identifier">x</span></code>
                with the sign copied from <code class="computeroutput"><span class="identifier">y</span></code>.
              </li>
</ul></div>
</div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2014 Peter Dimov<br>Copyright © 2014 Glen Fernandes<br>Copyright © 2014 Andrey Semashev<p>
        Distributed under the <a href="http://boost.org/LICENSE_1_0.txt" target="_top">Boost
        Software License, Version 1.0</a>.
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="checked_delete.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="default_allocator.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
